<?php
include("in.php");

if($_SESSION['status'] == 'processing')
{
	header("Location: search.php");
	die;
}
elseif($_SESSION['status'] != 'done')
{
	header("Location: index.php");
	die;
}

$tags = $_SESSION['tags'];
$items = $_SESSION['items'];

// build and display tag cloud
// build tag cloud
$tmp = array();
$tmp_tags = array_slice($tags, 20);
foreach($tmp_tags as $tag)
{
	$tmp[] = "<span>" . $tag->word . " (".$tag->score." - ".$tag->searched.")</span>";
}
$tag_cloud = implode(", ", $tmp);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>GoedKado</title>
  <meta name="description" content="">
  <meta name="author" content="">

  <meta name="viewport" content="width=device-width,initial-scale=1">

  <!-- CSS concatenated and minified via ant build script-->
  <link rel="stylesheet" href="css/style.css">
  <!-- end CSS-->

  <script src="js/libs/modernizr-2.0.6.min.js"></script>
</head>

<body>
			
	<div id="overviewcontainer" class="clearfix">
		<form method="post" action="search.php" id="search">
			<div class="searchheaderlinks">
					<a href="#">over goed kado</a>
					<a href="#">meer uitleg</a>
			</div>
			<div class="searchcontent">
				<img src="img/kiesvoor.gif" height="25" width="414" alt="" /><input type="text" name="input" />
			</div>
		</form>
		
		<div class="tagcloud">
			<?=$tag_cloud;?>
		</div>
		
		<div class="products clearfix">
			<?php
			
			$items = array_slice($items, 0, 9);
			
			for($i=0;$i<count($items);$i++)
			{
				if($i%3==0&&$i!=0) echo "<div style='clear: both;'>&nbsp;</div>";
				
				$item = $items[$i];
				
				$item_tags = array();
				foreach($item->tags as $tag)
				{
					$item_tags[] = "<span>".$tag->word."</span>";
				}
				$item_tag_cloud = implode(", ", $item_tags);
				?>
				<div class="topproducts">
				<h1><?=$item->title;?></h1>
				<span class="price">&euro; 6,45</span>
				<img src="<?=$item->image;?>" style="width:200px;" />
				<p>Tags: <?=$item_tag_cloud;?></p>
				</div>
				<?php
			}
			?>
		</div>
	</div>

  <script src="jquery.min.js"></script>

  <!-- scripts concatenated and minified via ant build script-->
  <script defer src="js/script.js"></script>
  <!-- end scripts-->

  <!--[if lt IE 7 ]>
    <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
    <script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
  <![endif]-->
  
</body>
</html>
?>